<template>
	<view class="content">
		<u-navbar :title="navtitle" :border-bottom="false" back-icon-color="#ffffff" title-color="#fff" :background="{backgroundColor:'#2A2931'}"></u-navbar>
		<view class="list">
			<user-item v-for="(item,index) in collist" :item="item"></user-item>
		</view>
	</view>
</template>

<script>
	import userItem from '@/components/user-item.vue'
	export default {
		components: {
			userItem
		},
		data() {
			return {
				HOSTURL:this.$HOSTURL,
				collist:[],
				more: false,
				page: 1,
				types: 1, // 1我喜欢的 2喜欢我的
				visitor: 0
			}
		},
		onLoad(options) {
			if(options){
				if(options.types){
					this.types = options.types
				}
				if(options.types){
					this.visitor = options.visitor
				}
			}
			this.getcollist()
		},
		methods: {
			async getcollist(){
				const { data: res } = await this.$Request({
					url: this.visitor ? 'apis/home/Dymanic/visit' :'apis/home/Dymanic/myattention',
					data:{
						user_id: this.$store.state.userid,
						pagecount: 10,
						pagesize: 10,
						page: this.page,
						types: this.types
					}
				})
				this.more = res.result.length == 10
				console.log(res);
				this.collist = this.collist.concat(res.result)
			},
			userinfo(index,id){
				if(this.$store.state.userinfo.sex == this.collist[index].user_sex){
					return uni.showToast({
						title:'不可查看同性的详细信息',
						icon:'none'
					})
				}
				uni.navigateTo({
					url:'/pages/userinfo/index?id=' + id
				})
			}
		},
		computed:{
			navtitle () {
				return this.visitor?'看过我的':(this.types==1?'我喜欢的':'喜欢我的')
			}
		},
		onReachBottom(){
			if(this.more){
				this.page++
				this.getcollist()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		background: #2A2931;
		min-height: 100vh;
		.list{
			padding: 10rpx 0rpx;
		}
	}
	
</style>
